package org.newlucene.core.analysis;

import java.io.IOException;

public class StemAnalyzer implements Analyzer
{
    private Analyzer analyzer;
    private PorterStemmer stemmer = new PorterStemmer();
    
    public StemAnalyzer(Analyzer analyzer)
    {
        this.analyzer = analyzer;
    }
    
    public Token next() throws IOException
    {
        Token t = analyzer.next();
        if (t == null)
        {
            return null;
        }
        return new Token(stemmer.stem(t.termText));
    }

    public void set(String text)
    {
        analyzer.set(text);
    }
}
